#ifndef __WXD_COMMANAGER_H__
#define __WXD_COMMANAGER_H__

#include "defs.h"
#include "singleton.h"

class WXDLLIMPEXP_FWD_DIRECTUI wxDComponent;

WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxDComponent*, wxDComponentDict, class WXDLLIMPEXP_DIRECTUI);

class WXDLLIMPEXP_DIRECTUI wxDComponentManager : public wxDSingleton<wxDComponentManager>
{
public:
	wxDComponentManager();
	~wxDComponentManager();

	void Add(wxDComponent* component);
	void Delete(const wxString& id);
	void DeleteAll();

	template<typename T>
	T* Get(const wxString& id) const
	{
		wxDComponentDict::const_iterator it = mComDict.find(id);
		if (it != mComDict.end())
		{
			return static_cast<T*>(it->second);
		}
		return NULL;
	}

	static wxDComponentManager& GetSingleton();
	static wxDComponentManager* GetSingletonPtr();

private:
	wxDComponentDict mComDict;
};

#endif